package com.linq.cool.beauty.domain;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Objects;

/**
 * @Author: yqlin
 * @Date: 2021/2/9 14:06
 * @Description: 收藏(mongodb)
 * @Version: 1.0.0
 */
@Data
@Accessors(chain = true)
@Document("beauty_product_collection")
public class BeautyProductCollection implements Serializable {
    @JsonSerialize(using = ToStringSerializer.class)
    @Id
    private Long id;
    /**
     * 客户id
     */
    @JsonSerialize(using = ToStringSerializer.class)
    @Field("member_id")
    private Long memberId;
    /**
     * 商品id
     */
    @JsonSerialize(using = ToStringSerializer.class)
    @Field("product_id")
    private Long productId;
    /**
     * 商品图片
     */
    @Field("product_pic")
    private String productPic;
    /**
     * 商品名称
     */
    @Field("product_name")
    private String productName;
    /**
     * 商品品牌id
     */
    @Field("product_brand_id")
    private Long productBrandId;
    /**
     * 商品品牌名称
     */
    @Field("product_brand_name")
    private String productBrandName;

    @Field("product_price")
    private BigDecimal productPrice;

    @Field("product_category_id")
    private Long productCategoryId;

    @Field("create_time")
    private String createTime;

    /**
     * 购物车移入mongo时使用
     *
     * @param o
     *
     * @return
     */
    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        BeautyProductCollection that = (BeautyProductCollection) o;
        return productId.equals(that.productId) &&
                memberId.equals(that.memberId);
    }

    @Override
    public int hashCode() {
        return Objects.hash(productId, memberId);
    }
}
